cucDefine(
    function(){
        function commonInit(dom, rootDom=null) {
            if(dom.hasAttribute("copy"));
            else dom.oncopy = ()=>{return false;};
            if(dom.hasAttribute("width")){
                rootDom && (rootDom.style.width = dom.getAttribute("width"));
            }
        }
        function loadStyle(dom, path) {
            let style = document.createElement('link');
            style.href = path;
            style.rel = "stylesheet";
            dom.appendChild(style);
            let comstyle = document.createElement('link');
            comstyle.href = "/cucoj/assets/component/common.css";
            comstyle.rel = "stylesheet";
            dom.appendChild(comstyle);
        }
        function loadScript(dom, path) {
            let script = document.createElement('script');
            script.src = path;
            dom.appendChild(script);
        }
        function copyText(text, callback){
            try {
                var tag = document.createElement('input');
                tag.setAttribute('id', 'cp_hgz_input');
                tag.value = text;
                document.getElementsByTagName('body')[0].appendChild(tag);
                document.getElementById('cp_hgz_input').select();
                document.execCommand('copy');
                document.getElementById('cp_hgz_input').remove();
                if(callback) {callback.success(text)}
            } catch(err) {
                if(callback) {
                    callback.fail(text)
                }
                console.error(err);
            }
        }
        var commonVar = {
            rootPath: "/cucoj"
        };
        return {
            commonInit,
            loadScript,
            loadStyle,
            copyText,
            commonVar
        };
    }
);